//=============================================================================
// FireChucker - It's a flamethrower.
//=============================================================================
class FireChucker extends WoEWeapon;

var() sound PilotLightAmbientSound;
var() class<emitter> PilotLightClass;
var emitter PilotLight;

//Change to blue projectiles if on blue team.
function GiveTo(Pawn Other, optional Pickup Pickup)
{
	Super.GiveTo(Other, Pickup);

	if(Other != None && FireMode[0] != None && FireMode[1] != None)
	{
		if(Other.GetTeam() != None && Other.GetTeam().TeamIndex == 1)
		{
			FireMode[0].ProjectileClass = FireChuckerFire(FireMode[0]).ProjectileClassBlue;
			FireMode[1].ProjectileClass = FireChuckerAltFire(FireMode[1]).ProjectileClassBlue;
		}
		else
		{
			FireMode[0].ProjectileClass = FireChuckerFire(FireMode[0]).Default.ProjectileClass;
			FireMode[1].ProjectileClass = FireChuckerAltFire(FireMode[1]).Default.ProjectileClass;
		}
	}
}

simulated function Timer()
{
	Super.Timer();

	if(ClientState == WS_BringUp || ClientState == WS_ReadyToFire)
	{
		if(PilotLight == None)
		{
			PilotLight = spawn(PilotLightClass);
			AttachToBone(PilotLight, 'tip');
			PilotLight.SetRelativeLocation(vect(16, 6, 0));
		}

		AmbientSound = PilotLightAmbientSound;
	}
	else
	{
		if(PilotLight != None)
			PilotLight.Destroy();

		AmbientSound = None;
	}
}

simulated function Destroyed()
{
	if(PilotLight != None)
		PilotLight.Destroy();

	Super.Destroyed();
}

simulated function bool HasAmmo()
{
	return (AmmoAmount(0) > 0 || FireMode[1].bIsFiring);
}

simulated function float ChargeBar()
{
	local float CurrentCharge, MaxCharge;

	//Store the int values as floats to avoid rounding errors.
	CurrentCharge = FireChuckerAltFire(FireMode[1]).GoopLoad;
	MaxCharge = FireChuckerAltFire(FireMode[1]).MaxGoopLoad;

	return FMin(1, CurrentCharge/MaxCharge);
}

defaultproperties
{
     PilotLightAmbientSound=Sound'TFMedia.FireChucker.PilotLightLoop'
     PilotLightClass=Class'taskforces.PilotLight'
     FireModeClass(0)=Class'taskforces.FireChuckerFire'
     FireModeClass(1)=Class'taskforces.FireChuckerAltFire'
     SelectAnim="Select"
     SelectSound=Sound'TFMedia.FireChucker.PilotLightOn'
     SelectForce="SwitchToShockRifle"
     AIRating=0.680000
     CurrentRating=0.680000
     bShowChargingBar=True
     Description="A perennial favourite with pyromaniacs everywhere, the FireChucker is the ultimate close support weapon. Primary fire is a standard flamethrower, capable of spewing burning death to a range of 40m. Secondary fire compresses fuel to be hurled as a ball of fire of variable size which will explode on impact. Because electronic systems are prone to EMP, it uses a low-tech pilot-light for ignition and is almost entirely mechanical in operation. This makes it heavy, but very robust and 100% reliable in the face of nuclear and electromagnetic based weapons."
     EffectOffset=(X=200.000000,Y=32.000000,Z=-25.000000)
     DisplayFOV=50.000000
     Priority=11
     SmallViewOffset=(X=24.000000,Y=12.000000,Z=-6.000000)
     CenteredOffsetY=2.000000
     CenteredRoll=512
     CenteredYaw=512
     CustomCrosshair=16
     CustomCrossHairColor=(B=0)
     CustomCrossHairScale=2.000000
     CustomCrossHairTextureName="Crosshairs.HUD.Crosshair_Triad3"
     InventoryGroup=7
     PickupClass=Class'taskforces.FireChuckerPickup'
     PlayerViewOffset=(X=16.000000,Y=8.000000,Z=-4.000000)
     PlayerViewPivot=(Yaw=-768)
     BobDamping=1.800000
     AttachmentClass=Class'taskforces.FireChuckerAttachment'
     IconCoords=(Y1=240,X2=90,Y2=278)
     ItemName="FireChucker"
     Mesh=SkeletalMesh'TFSentinelA.FireChucker1st'
}
